package zhoufu.sz.sanxiao_check.ui.train;

import android.view.Menu;
import android.view.MenuItem;
import zhoufu.sz.sanxiao_check.R;
import zhoufu.sz.sanxiao_check.inject.HasComponent;
import zhoufu.sz.sanxiao_check.inject.components.DaggerLoginComponet;
import zhoufu.sz.sanxiao_check.inject.components.LoginComponet;
import zhoufu.sz.sanxiao_check.ui.basic.BaseMsgActivity;

/**
 * User:RCP
 * email:ruancaipu@gmail.com
 * Date:2016/8/4
 * 场所培训
 */
public class TrainActivity extends BaseMsgActivity implements HasComponent<LoginComponet>
{
    LoginComponet mLoginComponet;

    @Override protected void initInject()
    {
        setTitle(R.string.title_train);
        mLoginComponet = DaggerLoginComponet.builder().activityModule(getActivityModule())
                .appComponent(getAppComponent()).build();
        mLoginComponet.inject(this);
        addFragment(R.id.main_fram, TrainListFragment.newInstance(mInfoModel.getSID()));
    }

    @Override protected int setIndividualId()
    {
        return R.layout.layout_frame;
    }

    @Override public LoginComponet getComponent()
    {
        return mLoginComponet;
    }

    @Override public boolean onCreateOptionsMenu(Menu menu)
    {
        getMenuInflater().inflate(R.menu.menu_train_add, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override public boolean onOptionsItemSelected(MenuItem item)
    {
        if ( item.getItemId() == R.id.menu_train_add )
        {
            _navigator.startAddTrainAct(this, mInfoModel.getSID());
        }
        return super.onOptionsItemSelected(item);
    }
}
